package com.lvchen.ui.twofunction;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.lvchen.R;
import com.lvchen.common.base.BaseFragment;
import com.lvchen.common.utils.UIHelper;
import com.siberiadante.titlelayoutlib.TitleBarLayout;

import java.util.ArrayList;
import java.util.List;


/**
 * 功能二
 */
public class TwoFragment extends BaseFragment {

    private TitleBarLayout tb_title;


    private ListView lv_ft;
    private TwoAdapter adapter;

    private List<String> savelist = new ArrayList<String>();

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        mContentView = inflater.inflate(R.layout.fragment_two, container, false);
        ensureUi();
        getData();
        return mContentView;
    }

    private void ensureUi() {

        tb_title = (TitleBarLayout) mContentView.findViewById(R.id.tb_title);
        tb_title.setIsHaveLine(false);
        tb_title.setLeftBackViewVisible(View.GONE);


        lv_ft = (ListView) mContentView.findViewById(R.id.lv_ft);

        adapter = new TwoAdapter(mActivity, savelist);
        lv_ft.setAdapter(adapter);

    }


    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);

    }

    @Override
    protected View getContentView() {
        return mContentView;
    }

    private void getData() {
        for (int i = 0; i < 20; i++) {
            String content = "黄金比例最好喝";
            savelist.add(content);
        }
        adapter.change(savelist);
    }

}